/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package slicktest.factories.marshallers.FileFilters;

import java.io.File;
import java.io.FilenameFilter;

/**
 * FileFilter that works based on a given file extension pattern,
 * simply give it ".ter" to filter on files that have .ter as an extension.
 * @author hailstorm
 */
public class FileExtensionFilter implements FilenameFilter {
    private final String pattern;

    public FileExtensionFilter(String pattern) {
        this.pattern = pattern;
    }    
    
    public boolean accept(File dir, String name) {
        boolean result = false;
        
        if(name.endsWith(pattern)) {
            result = true;
            System.out.println(name + " has extension: " + pattern);
        } else {
            System.out.println(name + " does not have extension: " + pattern);
        }
        
        return result;
    }    
}
